<template>
  <div id="app">
    <h1>Vuex - Demo </h1>
    <p>count: {{ $store.state.count }}</p>
    <p>msg: {{ $store.state.msg }}</p>
    <!-- <p>count: {{ count }}</p> -->
    <!-- <p>msg: {{ msg }}</p> -->
    <!-- <p>count: {{ num }}</p> -->
    <!-- <p>msg: {{ message }}</p> -->
    <h2>Getter</h2>
    <p>reverseMsg: {{ $store.getters.reverseMsg }}</p>
    <!-- <p>reverseMsg: {{ reverseMsg }}</p> -->

    <h2>Mutation</h2>
    <button @click="$store.commit('increate', 2)">Mutation</button>
    <!-- <button @click="increate(3)">Mutation</button> -->

    <h2>Action</h2>
    <button @click="$store.dispatch('increateAsync', 5)">Mutation</button>
    <!-- <button @click="increateAsync(6)">Mutation</button> -->

    <h2>Modules</h2>
    <!-- <p>products: {{ $store.state.products.products }}</p> -->
    <!-- <button @click="$store.commit('setProducts', [])">Mutation</button> -->
    <!-- <p>products: {{ products }}</p> -->
    <!-- <button @click="setProducts([])">Mutation</button> -->

    <h2>strict</h2>
    <button @click="$store.state.msg = 'lagou'">strict</button>
  </div>
</template>

<script>
// import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
export default {
  name: 'App',
  computed: {
    // count: state => state.count,
    // ...mapState(['count', 'msg']),
    // ...mapState({ num: 'count', message: 'msg' }),
    // ...mapGetters(['reverseMsg']),
    // ...mapState('products', ['products'])
  },
  methods: {
    // ...mapMutations(['increate']),
    // ...mapActions(['increateAsync']),
    // ...mapMutations('products', ['setProducts'])
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
